package com.ctshk.app.system.controller;

import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.common.req.OperationByIdReq;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.system.dto.MainDataBusinessTypeDTO;
import com.ctshk.rpc.system.dto.MainDataManualSystemDTO;
import com.ctshk.rpc.system.req.MainDataManualSystemCreateReq;
import com.ctshk.rpc.system.req.MainDataManualSystemQueryReq;
import com.ctshk.rpc.system.req.MainDataManualSystemUpdateReq;
import com.ctshk.rpc.system.service.IMainDataManualSystemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@Api(tags = "外挂系统主数据接口")
@RestController
@RequestMapping("/main/data/manual/system/")
public class MainDataManualSystemController extends BaseController {
	
	@DubboReference
	IMainDataManualSystemService mainDataManualSystemService;

	@ApiOperation("创建外挂系统主数据")
	@OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.ADD, operTitle = "创建外挂系统主数据", operDesc = "创建外挂系统主数据")
	@PostMapping("createData")
	public Result<Long> createData(@RequestBody @Valid MainDataManualSystemCreateReq req) {
		return mainDataManualSystemService.createData(req, getCurrentUser());
	}
	
	@ApiOperation("修改外挂系统主数据")
	@OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.UPDATE, operTitle = "修改外挂系统主数据", operDesc = "修改外挂系统主数据")
	@PostMapping("updateData")
	public Result<Void> updateData(@RequestBody @Valid MainDataManualSystemUpdateReq req) {
		return mainDataManualSystemService.updateData(req, getCurrentUser());
	}
	
	@ApiOperation("删除外挂系统主数据")
	@OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.DELETE, operTitle = "删除外挂系统主数据", operDesc = "删除外挂系统主数据")
	@PostMapping("deleteData")
	public Result<Void> deleteData(@RequestBody @Valid OperationByIdReq req) {
		return mainDataManualSystemService.deleteData(req, getCurrentUser());
	}
	
	@ApiOperation("启用/禁用外挂系统主数据")
	@OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.UPDATE, operTitle = "启用/禁用外挂系统主数据", operDesc = "启用/禁用外挂系统主数据")
	@PostMapping("changeStatus")
	public Result<Void> changeStatus(@RequestBody @Valid OperationByIdReq req) {
		return mainDataManualSystemService.changeStatus(req, getCurrentUser());
	}
	
	@ApiOperation("查询外挂系统主数据列表")
	@OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.QUERY, operTitle = "查询外挂系统主数据列表", operDesc = "查询外挂系统主数据列表")
	@PostMapping("queryList")
	public Result<PageResponse<MainDataManualSystemDTO>> queryList(@RequestBody @Valid MainDataManualSystemQueryReq req) {
		return mainDataManualSystemService.queryList(req);
	}
	
	@ApiOperation("查询外挂系统主数据字典列表")
	@OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.QUERY, operTitle = "查询外挂系统主数据字典列表", operDesc = "查询外挂系统主数据字典列表")
	@PostMapping("queryDictList")
	public Result<List<MainDataManualSystemDTO>> queryDictList(@RequestBody @Valid MainDataManualSystemQueryReq req) {
		return mainDataManualSystemService.queryDictList(req);
	}

	@ApiOperation("获取业务类型列表")
	@OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.QUERY, operTitle = "查询业务类型列表", operDesc = "查询业务类型列表")
	@GetMapping("getBusinessTypeList")
	public Result<List<MainDataBusinessTypeDTO>> queryBusinessTypeList() {
		return mainDataManualSystemService.queryBusinessTypeList();
	}
}
